package com.sch.hospital.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.CrossOrigin;
import com.sch.hospital.domain.Result;
import com.sch.hospital.domain.Feedback;
import com.sch.hospital.service.IFeedbackService;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 用户反馈Controller
 * 
 * @author ruoyi
 * @date 2025-06-30
 */
@Tag(name = "反馈相关接口")
@RestController
@RequestMapping("/system/feedback")
@CrossOrigin
public class FeedbackController
{
    @Autowired
    private IFeedbackService feedbackService;

    /**
     * 查询用户反馈列表
     */
    @GetMapping("/list")
    public Result list(Feedback feedback)
    {
        List<Feedback> list = feedbackService.selectFeedbackList(feedback);
        return Result.success(list);
    }

    /**
     * 获取用户反馈详细信息
     */
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(feedbackService.selectFeedbackById(id));
    }

    /**
     * 新增用户反馈
     */
    @PostMapping
    public Result add(@RequestBody Feedback feedback)
    {
        int rows = feedbackService.insertFeedback(feedback);
        return rows > 0 ? Result.success() : Result.error("新增用户反馈失败");
    }

    /**
     * 修改用户反馈
     */
    @PutMapping
    public Result edit(@RequestBody Feedback feedback)
    {
        int rows = feedbackService.updateFeedback(feedback);
        return rows > 0 ? Result.success() : Result.error("修改用户反馈失败");
    }

    /**
     * 删除用户反馈
     */
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        int rows = feedbackService.deleteFeedbackByIds(ids);
        return rows > 0 ? Result.success() : Result.error("删除用户反馈失败");
    }
}
